<?php
namespace app\admin\controller;
use app\common\controller\Admin;
class login extends Admin{
	public function index($username = '', $password = '', $verify = ''){
		if(member_login()){
			return $this->redirect('admin/index/index');
		}
		if ($this->request->isPost()) {
			if(empty($username) || empty($password)){
				return $this->error('用户名或者密码不能为空！', '');
			}
			//验证码验证
			if(config('system.system_verify')){
			    if(!captcha_check($verify)){
				    return $this->error('验证码错误！', '');
			    }
			}   
			$user = model('Member');
			$info=$user->login($username,$password);
			if ($info['member_id']){
				return $this->success('登录成功！', url('admin/index/index'));					
			}else{
				return $this->error($user->getError());
			}
		}
		return $this->fetch();
	}	
	// 用户登出
    public function logout(){
		if(session('member_auth')){
		   session('member_auth', null);
		   session('member_auth_sign', null);
		   return $this->success("退出成功", "admin/login/index");
		}else{
		   return $this->error("退出失败");
		}
    }	
}
// +----------------------------------------------------------------------
// | ZanPianCMS
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.zanpiancms.com All rights reserved.
// +----------------------------------------------------------------------
// | BBS:  <http://www.zanpiancms.cc>
// +----------------------------------------------------------------------
?>